package com.ruoyi.recoverCustomer.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.recoverCustomer.domain.TRecoverCustomerLog;
import com.ruoyi.recoverCustomer.domain.bo.TRecoverCustomerLogBo;
import com.ruoyi.recoverCustomer.domain.vo.TRecoverCustomerLogVo;
import com.ruoyi.recoverCustomer.mapper.TRecoverCustomerLogMapper;
import com.ruoyi.recoverCustomer.service.ITRecoverCustomerLogService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 客户回收记录Service业务层处理
 *
 * @author ruoyi
 * @date 2023-08-18
 */
@RequiredArgsConstructor
@Service
public class TRecoverCustomerLogServiceImpl implements ITRecoverCustomerLogService {

    private final TRecoverCustomerLogMapper baseMapper;

    /**
     * 查询客户回收记录列表
     */
    @Override
    public TableDataInfo<TRecoverCustomerLogVo> queryPageList(TRecoverCustomerLogBo bo, PageQuery pageQuery) {
        LambdaQueryWrapper<TRecoverCustomerLog> lqw = buildQueryWrapper(bo);
        Page<TRecoverCustomerLogVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
        return TableDataInfo.build(result);
    }

    /**
     * 查询客户回收记录列表
     */
    @Override
    public List<TRecoverCustomerLogVo> queryList(TRecoverCustomerLogBo bo) {
        LambdaQueryWrapper<TRecoverCustomerLog> lqw = buildQueryWrapper(bo);
        return baseMapper.selectVoList(lqw);
    }

    private LambdaQueryWrapper<TRecoverCustomerLog> buildQueryWrapper(TRecoverCustomerLogBo bo) {
        //Map<String, Object> params = bo.getParams();
        LambdaQueryWrapper<TRecoverCustomerLog> lqw = Wrappers.lambdaQuery();
        lqw.like(StringUtils.isNotBlank(bo.getCustomerName()), TRecoverCustomerLog::getCustomerName, bo.getCustomerName());
        lqw.like(StringUtils.isNotBlank(bo.getCustomerTel()), TRecoverCustomerLog::getCustomerTel, bo.getCustomerTel());
        lqw.eq(StringUtils.isNotBlank(bo.getLevel()), TRecoverCustomerLog::getLevel, bo.getLevel());
        lqw.eq(StringUtils.isNotBlank(bo.getOperatorDay()), TRecoverCustomerLog::getOperatorDay, bo.getOperatorDay());
        return lqw;
    }

}
